---
description: "Reference for Nitric's v0 JVM library - Sets the cron expression and one or many handlers to be triggered."
---

# JVM - schedule.cron()

Sets the cron expressions that determines when the schedule triggers and a callback to be triggered.

<Tabs syncKey="jvm-lang">

<TabItem label="Java">

```java
import io.nitric.Nitric;
import io.nitric.faas.v0.Frequency;

public class Application {
  public static void main(String[] args) {
    // Create a schedule that runs at 1:00am on the 1st of every month
    Nitric.INSTANCE.schedule("send-reminder").cron("0 1 1 * *", (ctx) -> {
      // add code to run here
      return ctx;
    });

    Nitric.run();
  }
}
```

</TabItem>

<TabItem label="Kotlin">

```kotlin
import io.nitric.Nitric
import io.nitric.faas.v0.Frequency

fun main() {
  // Create a schedule that runs at 1:00am on the 1st of every month
  Nitric.schedule("send-reminder").cron("0 1 1 * *") { ctx ->
    // add code to run here
    ctx
  }

  Nitric.run()
}
```

</TabItem>

</Tabs>

## Parameters

<Properties>
  <Property name="expression" required type="String">
    The expression that sets when the schedule will be triggered. This value
    should be a standard 5 value Unix cron expression, e.g., '0 1 1 * *'.
  </Property>
  <Property
    name="middleware"
    required
    type="EventMiddleware or List<EventMiddleware>"
  >
    One or more callback functions to use as the handler which will run on the
    defined frequency.
  </Property>
</Properties>

## Examples

### Create a Schedule

<Tabs syncKey="jvm-lang">

<TabItem label="Java">

```java
import io.nitric.Nitric;
import io.nitric.faas.v0.Frequency;

public class Application {
  public static void main(String[] args) {
    // every 15 minutes
    Nitric.INSTANCE.schedule("check for updates").cron("0/15 * * * *", (ctx) -> {
      System.out.println("checking for updates");
      return ctx;
    });

    // at 1:00am on the 1st of every month
    Nitric.INSTANCE.schedule("delete stale data").cron("0 1 1 * *", (ctx) -> {
      System.out.println("clearing data");
      return ctx;
    });

    Nitric.run();
  }
}
```

</TabItem>

<TabItem label="Kotlin">

```kotlin
import io.nitric.Nitric
import io.nitric.faas.v0.Frequency

fun main() {
  // every 15 minutes
  Nitric.schedule("check for updates").cron("0/15 * * * *") { ctx ->
    println("checking for updates")
    ctx
  }

  // at 1:00am on the 1st of every month
  Nitric.schedule("delete stale data").cron("0 1 1 * *") { ctx ->
    println("clearing data")
    ctx
  }

  Nitric.run()
}
```

</TabItem>

</Tabs>
